average value of a function